<?php
/**
 * Created by PhpStorm.
 * User: 曹乐清
 * Date: 2017/3/23
 * Time: 10:21
 */

namespace Api\Controller;


use Think\Controller;

class ClassifyController extends Controller
{
    //@todo 获取分类
    public function getClassify(){
        //先查询背景
        $bei_j=D('product')->select();
        $zhuang_s=D('decorate')->select();
        foreach($zhuang_s as $key=>$value){
            $list_next=D('decorate_next')->where(array('pid'=>$value['id']))->select();
            $zhuang_s[$key]['next_list']=$list_next;
        }
        echo json_encode(array('mate'=>array('code'=>0,'message'=>'调用成功'),'zh_shi'=>$zhuang_s,'bei_jin'=>$bei_j));
    }

    //@todo 查询列表
    public function getClassifyDetail_list(){
       $post=json_decode(file_get_contents('php://input'),true);
        if($post['product_type']=='1'){//查询背景
            $list=D('product_pic')->where(array('pid'=>$post['pid']))->limit($post['page'],10)->select();
        }else{//查询装饰
            $list=D('product_next_pic')->where(array('pid'=>$post['pid']))->limit($post['page'],10)->select();
        }

        foreach($list as $key=>$value){
            $list[$key]['thumb']='https://'.$_SERVER['HTTP_HOST'].'/Uploads/Cms/productPic/'.$value['thumb'];
            $list[$key]['pic']='https://'.$_SERVER['HTTP_HOST'].'/Uploads/Cms/productPic/'.$value['pic'];
            $list[$key]['product_type']=$post['product_type'];
        }
        $this->ajaxReturn(array('mate'=>array('code'=>0,'message'=>'调用成功'),'list'=>$list));
    }
}